package com.kzj.dao;

import com.kzj.domain.Exercises;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.time.LocalDate;


/**
 * <p>
 *  Mapper 接口
 * </p>
 *
 * @author kzj
 * @since 2023-11-15
 */
@Mapper
public interface ExercisesDao extends BaseMapper<Exercises> {
    @Select("select count(*) from exercises,equation where exercises.id=equation.exercises_id and exercises.type=#{type} " +
            "and exercises.user_phone=#{userPhone} and exercises.timing_time is not null and  exercises.create_type=1 " +
            "and equation.practice_correctly is not null")
    Integer getCountByTypeAndIsTimingTime(@Param("type") Integer type, @Param("userPhone") String userPhone);
    @Select("select count(*) from exercises,equation where exercises.id=equation.exercises_id and exercises.type=#{type} " +
            "and exercises.user_phone=#{userPhone} and exercises.timing_time is null and  exercises.create_type=1 " +
            "and equation.practice_correctly is not null")
    Integer getCountByTypeAndNoTimingTime(@Param("type")Integer addition,@Param("userPhone")String userPhone);
    @Select("select count(*) from exercises,equation where exercises.id=equation.exercises_id  and  exercises.create_type=1 " +
            "and exercises.user_phone=#{userPhone} and exercises.type=#{type} and exercises.timing_time is not  null " +
            "and equation.practice_correctly is not null and date(exercises.create_time)=#{date}")
    Integer getCountBYTypeAndIsTimingTimeAndData(@Param("type")Integer subduction,@Param("userPhone") String userPhone,@Param("date") LocalDate date);
    @Select("select count(*) from exercises,equation where exercises.id=equation.exercises_id  and  exercises.create_type=1 " +
            "and exercises.user_phone=#{userPhone} and exercises.type=#{type} and exercises.timing_time is   null " +
            "and equation.practice_correctly is not null and date(exercises.create_time)=#{date}")
    Integer getCountBYTypeAndNoTimingTimeAndData(@Param("type")Integer subduction,@Param("userPhone") String userPhone,@Param("date") LocalDate date);
    @Select("select count(*) from exercises,equation where exercises.id=equation.exercises_id  and  exercises.create_type=1 " +
            "and exercises.user_phone=#{userPhone} and exercises.type=#{type} and exercises.timing_time is not  null " +
            "and equation.practice_correctly = 1 and date(exercises.create_time)=#{date}")
    Integer getTureCountBYTypeAndIsTimingTimeAndData(@Param("type")Integer subduction,@Param("userPhone") String userPhone,@Param("date") LocalDate date);
    @Select("select count(*) from exercises,equation where exercises.id=equation.exercises_id  and  exercises.create_type=1 " +
            "and exercises.user_phone=#{userPhone} and exercises.type=#{type} and exercises.timing_time is   null " +
            "and equation.practice_correctly = 1 and date(exercises.create_time)=#{date}")
    Integer getTureCountBYTypeAndNoTimingTimeAndData(@Param("type")Integer subduction,@Param("userPhone") String userPhone,@Param("date") LocalDate date);
}
